package com.vehicle.coupon.config;

import com.vehicle.coupon.constant.RabbitmqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author:cocoKe
 * @Description:
 * @VERSON:1.8
 * @create:2025-04-07 21:00
 * @Date:2025/4/7
 */
@Configuration
public class RabbitmqConfig {

    @Bean
    public DirectExchange initExchange() {
        return new DirectExchange(RabbitmqConstants.EXCHANGE_NAME, true, false);
    }

    @Bean
    public Queue initQueue() {
        return new Queue(RabbitmqConstants.QUEUE_NAME, true);
    }

    //绑定
    @Bean
    public Binding initBinding() {
        return BindingBuilder.bind(initQueue()).to(initExchange()).with(RabbitmqConstants.ROUTING_KEY);
    }
}
